<?php

namespace app\models\nurse;

use Yii;

/**
 * This is the model class for table "nurse".
 *
 * @property integer $id
 * @property string $name
 * @property string $account
 * @property string $password
 * @property integer $idOfHospital
 * @property string $urlOfPortrait
 * @property string $job_num
 */
class Nurse extends \yii\db\ActiveRecord
{
    public $verify_data;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'nurse';
    }
    //定义场景
    public function scenarios()
    {
        return [
            'login' => ['account', 'password'],
            //'register' => ['username', 'email', 'password'],
        ];
    }
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['idOfHospital'], 'integer'],
            [['name'], 'string', 'max' => 40],
            [['account'], 'string', 'max' => 15],
            [['password'], 'string', 'max' => 12],
            ['account','required','message'=>'账户不能为空'],
            ['password','required','message'=>'密码不能为空'],
            [['urlOfPortrait'], 'string', 'max' => 150],
            [['job_num'], 'string', 'max' => 10],
            ['verify_data','required','message'=>'验证码不能为空'],
            ['verify_data','captcha','captchaAction'=>'nurse/login/captcha','message'=>'验证码不正确']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'account' => '账户名',
            'password' => '密码',
            'idOfHospital' => 'Id Of Hospital',
            'urlOfPortrait' => 'Url Of Portrait',
            'job_num' => 'Job Num',
            'verify_data' => '验证码'
        ];
    }

    /**
     * @inheritdoc
     * @return NurseQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new NurseQuery(get_called_class());
    }
}
